#—*—coding:utf-8 -*-
#@Time        :2022/7/18 13:48
#@Author      :dhx
#@File        :check_coulld_coll.py
# @Software: PyCharm
from time import sleep

from selenium.webdriver.common.by import By
from pages.finance_page import FinancePage

class CheckCould( FinancePage):
    url='http://192.168.3.133/crm/index.php?m=finance&a=view&t=receivables&id=7'
    increase_locator = (By.XPATH, '//*[@id="receivingorder"]')  # 添加新内容
    people_locator = (By.ID, 'owner_name')  # 负责人
    option_person_locator = (By.XPATH, '//*[@id="d_content"]/tr[1]/td[1]/input')  # 选择负责人
    ok_person_locator = (By.XPATH, '/html/body/div[10]/div[3]/div/button[1]')  # 点击保存
    price_locator = (By.ID, 'money')  # 金额
    time_locator = (By.ID, 'pay_time')  # 时间
    status_locator = (By.XPATH, '//*[@id="dialog-receivingorder"]/form/table/tbody/tr[6]/td[2]/input[2]')  # 状态
    description = (By.XPATH, '//*[@id="dialog-receivingorder"]/form/table/tbody/tr[7]/td[2]/textarea')  # 描述
    save_locator = (By.XPATH, '//*[@id="dialog-receivingorder"]/form/table/tfoot/tr/td[2]/input[1]')  # 添加
    delete_locator = (By.XPATH, '/html/body/div[5]/div[1]/div/a[2]')  # 删除

    def incress_click(self):
        """ 添加"""
        self.driver.find_element(*self.increase_locator).click()
        sleep(1)
    def option_person_click(self):
        """ 选择负责人"""
        self.driver.find_element(*self.people_locator).click()
        sleep(1)
    def first_person_click(self):
        """ 勾选第一个"""
        self.driver.find_element(*self.option_person_locator).click()
        sleep(1)
    def save_person_click(self):
        """  保存"""
        self.driver.find_element(*self.ok_person_locator).click()
        sleep(1)
    def time_click(self):
        """输入收款时间"""
        self.driver.find_element(*self.time_locator).send_keys("2022-07-02")
        sleep(1)
    def status_click(self):
        """选择状态"""
        self.driver.find_element(*self.status_locator).click()
        sleep(1)
    def desc_click(self):
        """输入描述"""
        self.driver.find_element(*self.description).send_keys("描述")
        sleep(1)
    def add_click(self):
        """输入描述"""
        self.driver.find_element(*self.save_locator).click()
        sleep(1)

    def delete_cli(self):
        """删除"""
        self.driver.find_element(*self.delete_locator).click()
        self.driver.switch_to.alert.dismiss()
        sleep(0.5)






